package com.buaa.daas.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.buaa.daas.entity.StuInfo;
import com.buaa.daas.mapper.StuInfoMapper;
import com.buaa.daas.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class LoginServiceImpl extends ServiceImpl<StuInfoMapper, StuInfo> implements LoginService {

    @Autowired
    private StuInfoMapper stuInfoMapper;

    @Override
    public boolean checkLogin(String stunum, String password) {

        HashMap<String, Object> map = new HashMap<>();
        map.put("stu_num",stunum);

        List<StuInfo> stuInfos = stuInfoMapper.selectByMap(map);
        if(stuInfos == null || stuInfos.size() <= 0){
            return false;
        }

        //账号密码相匹配那就说明登录状态为成功
        return password.equals(stuInfos.get(0).getStuPsd());
    }
}
